package TwoSeach;

import org.junit.Test;

/**
 * @BelongsProject: SeniorArchitect-LeetCode
 * @BelongsPackage: TwoSeach
 * @Author: zhuangxiaoyan
 * @CreateTime: 2023-11-04  17:55
 * @Description: TODO
 * @Version: 1.0
 */
public class 寻找比目标字母大的组祖雄安字母744 {

    public char nextGreatestLetter(char[] letters, char target) {
        int length = letters.length;
        if (target >= letters[length - 1]) {
            return letters[0];
        }
        int left = 0, right = length - 1;
        while (left < right) {
            int mid = (right - left) / 2 + left;
            if (letters[mid] > target) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return letters[left];
    }

    @Test
    public void test() {
        char a = nextGreatestLetter(new char[]{'c', 'f', 'j'}, 'g');
        System.out.println(a);
    }
}
